package text.adventure.input;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

import android.content.Context;


public class CSVDictReader {

	
	public List<String> convertCSVtoList(String filePath, String seperator, Context context)
	{
		return Arrays.asList(readFile(filePath, seperator, context));
	}
	
	private String[] readFile(String filePath, String seperator, Context context)
	{
		try {
        StringBuffer fileData = new StringBuffer(1024);
        BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open(filePath)));
        char[] buf = new char[1024];
        int numRead=0;
        while((numRead=reader.read(buf)) != -1){
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);
            buf = new char[1024];
        }
			reader.close();
			return fileData.toString().split(seperator);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
